package com.lanou.dllo.mynovel.fragment;

import android.support.v4.app.Fragment;
import android.util.SparseArray;

/**
 * Created by dllo on 15/10/27.
 * 用工厂类调用viewPager
 */
public class FragmentFactory {
    private static SparseArray<Fragment> fragmentStore = new SparseArray<>();

    public static Fragment creatFragment (int position) {
        Fragment fragment = fragmentStore.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new StoreBoutiqueFragment();
                    break;
                case 1:
                    fragment = new StoreUpdateFragment();
                    break;
                case 2:
                    fragment = new StoreRankingFragment();
                    break;
                case 3:
                    fragment = new StoreClassifiedFragment();
                    break;
                case 4:
                    fragment = new StoreSeekFragment();
                    break;
            }
            fragmentStore.put(position, fragment);
        }
        return fragment;
    }
}
